package board_mvc.handler;

import java.util.HashMap;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import board.BoardDBBean;
@Controller
public class DeleteProAction implements CommandHandler {
	@Resource( name="instance" )
	BoardDBBean dao;
	
	@RequestMapping("/deletePro")
	@Override
	public ModelAndView process(HttpServletRequest request, HttpServletResponse response) {
	Map<String,Object>map=new HashMap<String, Object>();

		int num = Integer.parseInt( request.getParameter( "num" ) );
		int pageNum = Integer.parseInt( request.getParameter( "pageNum" ) );
		String passwd = request.getParameter( "passwd" );
	
		// BoardDBBean dao = BoardDBBean.getInstance();
		int resultCheck = dao.check( num, passwd );
		
		if(resultCheck != 0){
			int result = dao.deleteArticle( num );
			map.put("result", result);
		}
		map.put("num", num);
		map.put("pageNum", pageNum);
		map.put("resultCheck", resultCheck);
			
		return new ModelAndView("deletePro",map);
	}

}
